You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/05-data-types/01-primitives-methods/article.md
+11-8Lines changed: 11 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,22 @@
1
1
# Methods of primitives
2
2
3
-
JavaScript allows us to work with primitives (strings, numbers etc) as if they were objects.
3
+
JavaScript allows us to work with primitives (strings, numbers, etc.) as if they were objects.
4
4
5
-
They also provide methods to call as such. We will study those soon, but first we'll see how it works, because, of course, primitives are not objects (and here we will make it even more clear).
5
+
They also provide methods to call as such. We will study those soon, but first we'll see how it works because, of course, primitives are not objects (and here we will make it even clearer).
6
6
7
-
Let's look at the key distinction between primitives and objects.
7
+
Let's look at the key distinctions between primitives and objects.
8
8
9
9
A primitive
10
-
: Is a value of a primitive type. There are 6 primitive types: `string`, `number`, `boolean`, `symbol`, `null` and `undefined`.
10
+
11
+
- Is a value of a primitive type.
12
+
- There are 6 primitive types: `string`, `number`, `boolean`, `symbol`, `null` and `undefined`.
11
13
12
14
An object
13
-
: Is capable of storing multiple values as properties.
14
-
Can be created with `{}`, for instance: `{name: "John", age: 30}`. There are other kinds of objects in JavaScript, e.g. functions are objects.
15
15
16
-
One of the best things about objects is that we can store a function as one of its properties:
16
+
- Is capable of storing multiple values as properties.
17
+
- Can be created with `{}`, for instance: `{name: "John", age: 30}`. There are other kinds of objects in JavaScript; functions, for example, are objects.
18
+
19
+
One of the best things about objects is that we can store a function as one of its properties.
17
20
18
21
```js run
19
22
let john = {
@@ -28,7 +31,7 @@ john.sayHi(); // Hi buddy!
28
31
29
32
So here we've made an object `john` with the method `sayHi`.
30
33
31
-
Many built-in objects already exist, such as those that work with dates, errors, HTML elements etc. They have different properties and methods.
34
+
Many built-in objects already exist, such as those that work with dates, errors, HTML elements, etc. They have different properties and methods.
0 commit comments