File tree Expand file tree Collapse file tree
JavaScript Interview/Day 7 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+
3+
4+ 1. const myFn = () => {
5+ console.log("hi");
6+ }
7+
8+ myFn() // hi
9+
10+ 2. function abc(a, b) {
11+ "use strict"
12+ let a = 100, b = 200
13+ return arguments[0] + arguments[1]
14+ console.log(a + b)
15+ }
16+
17+ console.log(abc(10, 20))// error
18+
19+ use strict is used to avoid the use of undeclared variables.
20+
21+
22+
23+ 3.
24+ var abc = 10;
25+ let xyz = 20;
26+
27+ console.log(window.abc, window.xyz); // error because abc is not defined in window object but xyz is defined in window object
28+ // window object is a global object in browser environment
29+ // purpose of window object is to store global variables and functions
30+
31+
32+
33+ 4.
34+ console.log(null == undefined); // true because both are equal in value null is equal to undefined
35+ console.log(null === undefined); // false because both are not equal in type undefind type is undefined and null type is object.
36+
37+ console.log(NaN == NaN); // false because nan is false in value and type is number
38+ console.log(NaN === NaN); // false because nan is false in value and type is number
39+
40+ 5.
41+ const str = "hello world";
42+ const formattedStr = str.replace(" ", "\n");
43+ console.log(formattedStr); // hello world because replace method only replace first occurance of the string in the string
44+
45+
46+
47+ 6. console.log(isNaN("fardeen")); // true because fardeen is not a number
48+ console.log(!'fardeen'); // false because fardeen is a string
49+ console.log(+false); // 0 because false is equal to 0
50+
51+ */
52+
53+
54+
55+
You can’t perform that action at this time.
0 commit comments