Skip to content

Commit cb3c83c

Browse files
committed
added 5 important buil in functions ..
1 parent ccf240e commit cb3c83c

1 file changed

Lines changed: 70 additions & 1 deletion

File tree

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,71 @@
11
# JavaScript
2-
The of this repo is to save my js programs. Basics of JavaScript. Beginner level.
2+
*JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions. The of this repo is to save my js programs. Basics of JavaScript. Beginner level.*
3+
4+
## Table of Contents
5+
6+
1. [Important Methods](#methods)
7+
8+
## Methods
9+
> Most important javascript build in methods
10+
11+
<a name="typeof"></a><a name="1.1"></a>
12+
- [1.1](#typeof) **typeof**: Returns the type.
13+
14+
```javascript
15+
console.log(typeof 44); // number
16+
17+
console.log(typeof 'something'); // string
18+
19+
console.log(typeof true); // boolean
20+
21+
let num = 12;
22+
console.log(typeof(num)); // number
23+
24+
```
25+
26+
<a name="toString"></a><a name="1.2"></a>
27+
- [1.2](#toString) **toString**: Returns the string representation of the number's value.
28+
29+
```javascript
30+
let num = 10;
31+
let n = num.toString();
32+
33+
console.log(typeof(num)); // number
34+
35+
console.log(typeof(n)); // string
36+
```
37+
38+
<a name="indexOf"></a><a name="1.3"></a>
39+
- [1.3](#indexOf) **indexOf**: Returns the first index at which a given element can be found in the array, or -1 if it is not present.
40+
41+
```javascript
42+
let str = "Hello world, welcome to the JS Universe.";
43+
console.log(str.indexOf("welcome")); // 13
44+
console.log(str.indexOf("wall")); // -1
45+
46+
const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];
47+
console.log(fruits.indexOf('Melon')); // 3
48+
49+
console.log(fruits.indexOf('klkljkh')); // -1
50+
```
51+
52+
<a name="lastIndexOf"></a><a name="1.4"></a>
53+
- [1.4](#lastIndexOf) **lastIndexOf**: Returns the last index at which a given element can be found in the array, or -1 if it is not present.
54+
55+
```javascript
56+
const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];
57+
console.log(fruits.lastIndexOf('Melon')); // 3
58+
59+
console.log(fruits.lastIndexOf('klkljkh')); // -1
60+
```
61+
62+
<a name="length"></a><a name="1.5"></a>
63+
- [1.5](#length) **length**: Returns the number of characters or size in a string or array.
64+
65+
```javascript
66+
const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];
67+
console.log(fruits.length); // 4
68+
69+
let str = "Hello world, welcome to the JS Universe.";
70+
console.log(str.length); // 40
71+
```

0 commit comments

Comments
 (0)