Skip to content

Commit cda7951

Browse files
committed
Presentation improved for all files in Javascript_Basics
1 parent 8e00081 commit cda7951

File tree

6 files changed

+66
-90
lines changed

6 files changed

+66
-90
lines changed
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Number Methods
22

3-
## Number methods allow you to easily work with numbers
4-
5-
**isFinite()**
3+
## isFinite()
64
Checks whether a value is a finite number.
75
Finite is a number that isn't infinite and can be measured or given a value.
86

@@ -16,48 +14,48 @@ Numbers that pass as finite:
1614
- decimals
1715
- equations
1816

19-
**.isInteger()**
17+
## .isInteger()
2018
Checks whether the value passed is an integer.
2119
It's return value will be a boolean (true / false)
2220

23-
**.isNaN()**
21+
## .isNaN()##
2422
Checks whether the value passed is NaN (Not a number) or if the value is a number
2523

2624
true = NaN
2725

28-
**.isSafeInteger()**
26+
## .isSafeInteger()
2927
Checks whether the method passed is a safe integer. The returned value will provide a boolean.
3028

3129
A safe integer is represented as an IEEE-754 double precision number. This is simply any number between -9007199254740991 and 9007199254740991.
3230

3331
Note that the value isn't changed to a number if a string is passed in.
3432

35-
**.toExponential()**
33+
## .toExponential()
3634
Converts a number to its exponential form. The returned value is a string that represents the Number object in exponential notation
3735

38-
**.toFixed()**
36+
## .toFixed()
3937
Formats a number using the fixed-point notation. It allows you to format a number with a specific number of digits to the right of the decimal. Numbers will be rounded if necessary.
4038

4139
Its return value is a string with the given number using fixed-point notation. If the number given is negative, the return value will be a number and won't be converted into a string.
4240

43-
**.toLocaleString()**
41+
## .toLocaleString()
4442
Converts a number into a language-sensitive representation of said number.
4543
It can take in two optional parameters:
4644
- locales: A string with a language tag (bali, latn)
4745
- options: A set of options for the given locale (currency, style)
4846

4947
The return value is a string.
5048

51-
**.toPrecision()**
49+
## .toPrecision()
5250
Converts a number to the specified precision.
5351

5452
The returned value is in the form of a string. The value will be rounded and padded with 0's if there are not enough digits.
5553

56-
**.toString()**
54+
## .toString()
5755
Converts a given number to a string with the specified base number (an integer between 2 and 36)
5856

5957
The return value is given in the form of a string if no radix is given.
6058

61-
**.valueOf()**
59+
## .valueOf()
6260
Returns the number value in primitive form of a Number object.
6361
This is rarely something done on your own, as JavaScript invokes this automatically.

docs/JavaScript_Basics/regex.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ var re = new RegExp('pattern', 'flags');
1717

1818
In each of these cases, the variable `re` is a regex, and 'pattern' and 'flags' are placeholders that we will learn about next.
1919

20-
## Anatomy of a Regex
21-
22-
### Simple Character Patterns
20+
## Simple Character Patterns
2321
A Regex can be constructed from simple characters, like 'a', 'b', and 'c', or special characters such as '()', '*', and '$'. A Regex using simple characters simply searches for an exact match of that combination of characters within the searched string. The most basic example of a regex would be:
2422

2523
```js
@@ -36,7 +34,7 @@ console.log(result);
3634
// expected output: 0 since 'abc' is found at index 0 of exampleString
3735
```
3836

39-
### Special Character Patterns
37+
## Special Character Patterns
4038
Once you are ready to perform more complex searches on strings, you will want to start using special characters. There are a lot of special characters that can be used, so only a select few will be covered below, and a reference with explanations for the exhausive list of characters can be found at the bottom of the document.
4139

4240
- `/[abc]/` specifies a character set which matches any one of the characters within the brackets. Unlike `/abc/`, `/[abc]/` matches on indices 0, 1, and 2 of the example string used in the Simple Character Patterns example. An alternative syntax for `/[abc]/` is `/[a-c]/`.
@@ -60,7 +58,7 @@ console.log(result2);
6058
- `/^abc/` uses the '^' special character outside of the context of square brackets. In this case, the '^' special character refers to the beginning of the search string. A search using this regex would succeed for the test string 'abcdefg' since the simple character pattern 'abc' does occur at the beginning of the test string.
6159
- `/efg$/` uses the '$' special character, which refers to the end of the search string. A search using this regex would also succeed for the test string 'abcdefg' since this test string ends in the simple character pattern 'efg'.
6260

63-
### Flags
61+
## Flags
6462
Flags are placed at the end of Regex, and allow for an even more robust set of search possibilities. They can be used together or independently regardless of order. Two of the most commonly used flags are:
6563

6664
- `g`: Global search. This allows the regex to be applied to the entire test string, regardless of whether a match has already been found.

docs/JavaScript_Basics/splice_slice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ languages.splice(2, 1, "Python", "Pearl");
2626
This will add Python and Perl starting at index 2 and delete one element which was at index 2 originally.
2727
As of result we get an output of `["C++", "Java", "Python", "Pearl", "R"]`
2828

29-
#### Example 3: Deleting an element at a specific index
29+
#### Example 3: Deleting an element at a specific index
3030

3131
```javascript
3232
let languages = ["C++", "Java", "Javascript", "R"];

docs/JavaScript_Basics/string-concat.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/JavaScript_Basics/string_operation.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,57 @@ const variableName = "Hello JavaScript";
99
const variableName = 'Hello JavaScript';
1010
```
1111

12-
### Concatenation
13-
First way of doing string concatenation is using **+** operator
14-
```javascript
15-
const name = "Richard";
12+
## Concatenation
1613

17-
const text = "Hello " + name;
14+
String concatenation is joining 2 or more strings together in one string
1815

19-
console.log(text); // Hello Richard
20-
```
21-
Or using **template literals**. More convenient way for manipulating strings contains many variables.
22-
```javascript
23-
const name = "Richard";
16+
There are several method to achieve this in javascript and here we will mention some:
2417

25-
// Use backticks ( ` ) inside quotes and put variables inside ${}
26-
const text = `Hello ${Richard}`;
18+
1. Using .concat() method ( same as Array.concat() method )
19+
```javascript
2720

28-
console.log(text); // Hello Richard
29-
```
21+
let str = 'hello '.concat('world!')
22+
console.log(str) // hello world!
23+
24+
let user = 'jack'
25+
console.log('welcome '.concat(user)) // welcome jack
26+
27+
```
28+
29+
2. Using plus operator
30+
```javascript
31+
32+
let str = 'hello ' + 'world!'
33+
console.log(str) // hello world!
34+
35+
let user = 'jack'
36+
console.log('welcome '+ user) // welcome jack
37+
38+
```
39+
2. Using Template literals (Template strings):
40+
- using back-ticks
41+
- new feature from ES6
42+
- you can add multiple lines in one string without the need to add \<br\> tags or \n special character
43+
```javascript
44+
45+
let str = `hello world!`
46+
console.log(str) // hello world!
47+
48+
let user = 'jack'
49+
console.log(`welcome ${jack}`) // welcome jack
50+
51+
console.log(`this is
52+
a multiline string
53+
created by Template literals`)
54+
// output :
55+
//this is
56+
//a multiline string
57+
//created by Template literals
58+
59+
// ES5 version
60+
console.log('this i\na multiline string\ncreated by Template literals')
61+
// output :
62+
//this is
63+
//a multiline string
64+
//created by Template literals
65+
```

docs/JavaScript_Basics/this.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Window {postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, parent: Window, …}
1818

1919
```
2020

21-
## 'this' in a function
21+
## 'this' in a function
2222

2323
In JavaScript, by default the owner of the function is `this`. The value of this in a function refers to the object it belongs to. In below example, `this` refers to window object, so instead of printing '5' it refers to global value '10'.
2424

@@ -58,7 +58,7 @@ printX();
5858
*/
5959
```
6060

61-
## 'this' in a method
61+
## 'this' in a method
6262

6363
In JavaScript, `this` in a method refers to the object of which the method belongs to. In below example, the `printX` method belongs to person object. so `this` refers to person object.
6464

0 commit comments

Comments
 (0)