-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.js
More file actions
131 lines (101 loc) · 3.86 KB
/
a.js
File metadata and controls
131 lines (101 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// javascript syntax, with seo - oct 15 2024
//****************************** Nice and simple data types ***********************************
let a = 23e5;
let s = "strings are like this"
let b, c, d, e, f, g = 2.1718 * 3.1415; // expression here equates to a value
let caseSensitive = "remember";
caseSensitive += ":";
let casesensivite = "variables in javascript are case sensitive!";
let conc = "string " + "concatenation " + "is done with the " + "+ operator";
let arr = [ 3, 2, 3, 4, 5 ]
let und;
//****************************** OBJECT LITERAL ***********************************
const obj = {
cooldown: 5,
name: "bing",
last: "go",
id: 2362342,
// print hi - n times
print_hi : function (n) {
for (let i = 0; i < n; i++)
{
console.log("hi");
}
}, // oops, don't forget comma. Functions are pretty much stored as a property
printInfo() {
console.log("***** OBJECT INFO ******")
console.log(this.cooldown);
console.log(this.name);
console.log(this.last);
console.log(this.id)
// more sane than output streams lol!!
}
};
//****************************** EMPTY OBJECT ***********************************
const emptyobj = {};
emptyobj.name = "bing";
emptyobj.id = 2;
emptyobj.assetTag = 253.321;
//****************************** MODIFYING A CONST OBJECT????? O.O ********** loll
//****************************** NEW OBJECT ***********************************
const newobj = new Object(); // Jet-brains suggests using empty object instead {}
newobj.name = "bing go";
newobj.id = 5;
console.log(a);
console.log(conc);
console.log(caseSensitive, casesensivite);
console.log("type for javascript object: "+ typeof(obj));
console.log("type for javascript array: "+ typeof(arr));
console.log("type for javascript number: "+ typeof(a));
console.log("type for javascript underfined: "+ typeof(und));
// member data accessing
console.log(newobj["name"]); // this feels illegal
console.log(newobj.id);
console.log(emptyobj.assetTag);
console.log(obj["last"]) // why
obj.printInfo();
obj.print_hi(10);
//****************************** OBJECT PROPERTIES ACESSED BY REFERENCE ************************
let obj_reference = obj; // no copy here.
obj_reference.name = "john";
obj_reference.last = "doe";
obj.printInfo(); // take a look, obj values are modified via the referenced obj_reference.
// you can also delete properties
delete obj_reference.cooldown;
obj.printInfo(); // take a look, obj values are modified via the referenced obj_reference
//******************************* NESTED OBJECT ************************************************
const nested = {
value: 3,
grades: [2, 3, 4, 5, 3],
nestedobj: {
name: "john",
last: "bingo"
}
}
console.log(" Accessing nested object via the dot-operator. Full name: " +
nested.nestedobj.name + " " +
nested.nestedobj.last )
//******************************* Creating Literals : Examples *****************************
""; // string
324; // number
false; // boolean
null; // null
{}; // object object
[]; // array object
/()/; // regexp object
//******************************* HTML EVENTS *****************************
//******************************* HTML EVENTS *****************************
//******************************* HTML EVENTS *****************************
function changeSubmitText() {
console.log(" submit button clicked!! ")
// just to test
const textbox = document.getElementById("txtarea");
const title = document.getElementById("message-title");
title.innerHTML = textbox.value;
}
function changeSendText() {
console.log(" send button clicked!! ")
const textbox = document.getElementById("feedback-txt");
const title = document.getElementById("message-title");
title.innerHTML = textbox.value;
}