This is very common interview question in javascript most of the interviewer asked this kind of question the very basic example is 1 == ‘1’ The result of this answer is true because when we compare two values using double equal then it comapares only value but 1 === ‘1’ this giv...
It decides what thethiskeyword will point at based on what object is used to invoke thesayHellofunction. Looking at both call sites in the example above, we can tell that thethiskeyword will be equal to the object in front of the function call. Sogreet2.sayHello()says invoke the function...
But NaN is not equal to itself. It means that for NaN equality is anti-reflexive, while inequality is reflexive. Hence the name. Copy >NaN==NaNfalse>NaN!=NaNtrue Second, how to get NaN in JavaScript? If we try to make a number from a non-numeric string, JavaScript will not throw a...
The following syntax will show you how you can assign a variable with a value equal to NaN and the syntax of using the isNaN() method in JavaScript ? Number.isNaN OR isNaN(Number); In the above syntax, we have assigned the variable with the NaN value and then check if it is NaN...
What does "object destructuring" mean and what is the result of a destructuring operation?Say you have an object with some properties:const person = { firstName: 'Tom', lastName: 'Cruise', actor: true, age: 57 }You can extract just some of the object properties and put them into ...
If p is a false value, !p is true, and !!p is false. If p is a true value, !p is false, and !!p is true. Truthy and Falsy Values In JavaScript values are inherentlytruthyorfalsywhen evaluated in a boolean context. The !! operator uses this behavior to convert any value totrue...
An enum type isa special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. What is the benefit of enum in Java? Enum provides type-safe; Enum variable can be assigned only with...
So, what is the difference between a normal function and an arrow function? 🤔️ 1. this points to In JavaScript, thethisis a basic and important knowledge point. 1.1 Ordinary functions In ordinary functions,thisis dynamic, and its value depends on how the function is called. There are...
Always. But what you want is this to equal world object.That's why this inside of the arrow function equals the global object: window in a browser. 'Hello, ${this.who}!' evaluates as Hello, ${windows.who}!, which in the end is 'Hello, undefined!'....
== is the type-converting equality operator. It converts types for the check if necessary and then checks strict value equality. === is the strict equality operator. Variables are only equal if they have the same type and the same value. yes but even if the data value is the same, if...