1yarn add typed.js
2// or
3npm install typed.js
4// or
5bower install typed.js
6
7// in js file:
8import Typed from 'typed.js';
9
10const options = {
11 strings: ['<i>First</i> sentence.', '& a second sentence.'],
12 typeSpeed: 40
13};
14
15const typed = new Typed('.element', options);
1//String Data Type
2var strSingle = 'John'; //String with single quotes
3var strDouble = "Bob"; //String with double quotes
4
5//Number Data Type
6var num = 25; //Integer
7var flo = 80.5; //Floating-point number
8var exp = 4.25e+6; //Exponential notation, this equates to 4250000
9
10//Boolean Data Type
11var isReading = true; //Yes, I'm reading
12var isSleeping = false; //No, I'm not sleeping
13
14//Undefined Data Type
15var undef; //If a value is never assigned, any output will be 'undefined'
16
17//Null Data Type
18var noValue = null; //Null meaning that it is has no value, not the same as 0 or ""
19
20//Object Data Type
21var emptyObject = {};
22var person = {"name": "Clark", "surname": "Kent", "age": "36"}; //The quotes around the propety name can be omitted if the property name is a valid JS name
23var car = { //Same as person but easier to read
24 model: "BMW X3", //Example with quotes around property name ommitted
25 color: "white",
26 doors: 5
27}
28
29//Array Data Type
30var emptyArray = []; //An array can be of any data types (string, number, boolean, etc.)
31var array = ["One", "Two"] //String array, note the index of the first element is 0
32
33//Function Data Type
34var func = function() { //Calling the function: func();
35 alert("Code excuted"); //Outputs: Code executed
36}
37
38var funcVar = function(amount) { //Calling the function: funcVar(6);
39 alert("Code excuted " + amount + " times"); //Outputs: Code executed 6 times (if input was 6)
40}
41
42//Typeof Operator
43typeof variable; //Returns the data type of the variable
1// Can also be included with a regular script tag
2import Typed from 'typed.js';
3
4var options = {
5 strings: ['<i>First</i> sentence.', '& a second sentence.'],
6 typeSpeed: 40
7};
8
9var typed = new Typed('.element', options);