const obj = {
lang: "js"
};
let x = Object.create(obj);
delete x.lang;
console.log(x.lang) // "js"
This is beacause of the act of "Object.create" it stores the values of the object in the prototype (proto) and the delete keyword does not delete anything from the prototype (proto)
console.log(x) // undefined
var x = 10;
This is called hoisting this code will be compiled and be like this
var x; console.log(x) // undefined x = 10;This only works with var keyword and does not work for let and const, so make that in mind. this works also with functions for example
sayHello(); function sayHello() { console.log("Hello, World!") }
(function (lang) {
console.log(`Hello, ${lang}!`)
})("javascript") // Hello, javascript!
Yes you can do this. this is called IIFE it stands for immediately invoked function expression
[10] === 10 // is false
[10] == 10 // is true
'10' == 10 // is true
'10' === 10 // is false
[] == 0 // is true
[] === 0 // is false
'' == false // is true but true == "a" is false
'' === false // is false
The == (or !=) operator performs an automatic type conversion if needed. The === (or !==) operator will not perform any conversion. It compares the value and the type, which could be considered faster than ==.