console.log({}+[]); //[object Object]
//================================
console.log({}+{}); //[object Object][object Object]
//================================
console.log(1+'1'); //11
//================================
console.log(1-'1'); //0
//================================
console.log([]+[]); //""
//================================
console.log([]-[]); //0
//================================
console.log([]*[]); //0
//================================
let arrray =[1,2,3,3,4,4,5]; //remove repeated elements
console.log([...new Set(arrray)]); //[1,2,3,4,5]
//================================
let func = function(){
{
let l="let";
var v ="var";
}
console.log(v); //var
console.log(l); //error
}
func();
//================================
//to make var and let variable values not accessible outside of the function
let func = function(){
{
(function(){
let l="let";
var v ="var";
})();
}
console.log(v);
console.log(l);
}
func();
//================================
console.log(5<6<7); //true
console.log(5>6>7); //false
//================================
// true treat as 1
console.log(true < 7); //true
console.log(true > 7); //false
//================================
let X = function(){
return
{ // after return there should not be any line break if any line break then return; will be treated as do // not return any thing.
message:'Hi'
}
}
console.log(X()); //undefined
//================================
let X = function(){
return{
message:'Hi'
}
}
console.log(X()); //return message:Hi with an object
//================================
let profile = {
name: 'Ashish'
}
//Object.freeze(profile); //if we freeze the object then further can't modify the existing object
//property values and also can't add new property
profile.name="Ashish Kumar Verma";
profile.age=34;
console.log(profile.name); //disply -Ashish
console.log(profile.age); // display -undefined
//================================
let profile = {
name: 'Ashish'
}
//if we use seal() inplace of freeze() method with the current object then we can modifed only existing object property
// but can not add any new property with current object.
Object.seal(profile);
profile.name="Ashish Kumar Verma";
profile.age=34;
console.log(profile.name); //disply -Ashish Kumar Verma
console.log(profile.age); // display -undefined
//================================
let profile = {
name: 'Ashish'
}
Object.defineProperty(profile,'age',{
value:4,
writable:false // true then modify age value and if false then can not modify values of age
})
profile.name="Verma Kumar Ashish";
profile.age=10;
console.log(profile.name);
console.log(profile.age);
====================================
function a(){
return "Hello,Function";
}
const sentance= a 'Hi';
const sentance= a('Hi');
console.log(sentance);//error
//================================
<div contentEditable="true">Ashish</div>
//================================
function y(){
console.log(this.length);
}
var x={
length:5,
method:function(y){
arguments[0]();
}
};
x.method(y,1); //2
//================================
const x='constructor';
console.log(x);
console.log(x[x]);
console.log(String(01)); //"1"
console.log(x[x](01)); //"1"
//================================
console.log({}+{}); //[object Object][object Object]
//================================
console.log(1+'1'); //11
//================================
console.log(1-'1'); //0
//================================
console.log([]+[]); //""
//================================
console.log([]-[]); //0
//================================
console.log([]*[]); //0
//================================
let arrray =[1,2,3,3,4,4,5]; //remove repeated elements
console.log([...new Set(arrray)]); //[1,2,3,4,5]
//================================
let func = function(){
{
let l="let";
var v ="var";
}
console.log(v); //var
console.log(l); //error
}
func();
//================================
//to make var and let variable values not accessible outside of the function
let func = function(){
{
(function(){
let l="let";
var v ="var";
})();
}
console.log(v);
console.log(l);
}
func();
//================================
console.log(5<6<7); //true
console.log(5>6>7); //false
//================================
// true treat as 1
console.log(true < 7); //true
console.log(true > 7); //false
//================================
let X = function(){
return
{ // after return there should not be any line break if any line break then return; will be treated as do // not return any thing.
message:'Hi'
}
}
console.log(X()); //undefined
//================================
let X = function(){
return{
message:'Hi'
}
}
console.log(X()); //return message:Hi with an object
//================================
let profile = {
name: 'Ashish'
}
//Object.freeze(profile); //if we freeze the object then further can't modify the existing object
//property values and also can't add new property
profile.name="Ashish Kumar Verma";
profile.age=34;
console.log(profile.name); //disply -Ashish
console.log(profile.age); // display -undefined
//================================
let profile = {
name: 'Ashish'
}
//if we use seal() inplace of freeze() method with the current object then we can modifed only existing object property
// but can not add any new property with current object.
Object.seal(profile);
profile.name="Ashish Kumar Verma";
profile.age=34;
console.log(profile.name); //disply -Ashish Kumar Verma
console.log(profile.age); // display -undefined
//================================
let profile = {
name: 'Ashish'
}
Object.defineProperty(profile,'age',{
value:4,
writable:false // true then modify age value and if false then can not modify values of age
})
profile.name="Verma Kumar Ashish";
profile.age=10;
console.log(profile.name);
console.log(profile.age);
====================================
function a(){
return "Hello,Function";
}
const sentance= a 'Hi';
const sentance= a('Hi');
console.log(sentance);//error
//================================
<div contentEditable="true">Ashish</div>
//================================
function y(){
console.log(this.length);
}
var x={
length:5,
method:function(y){
arguments[0]();
}
};
x.method(y,1); //2
//================================
const x='constructor';
console.log(x);
console.log(x[x]);
console.log(String(01)); //"1"
console.log(x[x](01)); //"1"
No comments:
Post a Comment