We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent be42de4 commit 9ab0352Copy full SHA for 9ab0352
part1 (Basics)/18_type.js
@@ -0,0 +1,20 @@
1
+// Type Operators in JavaScript
2
+
3
+/*
4
+typeof Returns the data type of a variable or expression.
5
+instanceof Checks if an object is an instance of a constructor.
6
+in Checks if a property exists in an object.
7
+*/
8
9
+// typeof
10
+console.log(typeof 42); // Output: "number"
11
+console.log(typeof 'hello'); // Output: "string"
12
13
+// instanceof
14
+console.log([] instanceof Array); // Output: true
15
+console.log({} instanceof Object); // Output: true
16
17
+// in
18
+const person = {name: 'Alice', age: 25};
19
+console.log('age' in person); // Output: true
20
+console.log('salary' in person);// Output: false
0 commit comments