Showing
9 changed files
with
108 additions
and
0 deletions
| 1 | +function addPrice(amount) { | ||
| 2 | + this.price = amount; | ||
| 3 | +} | ||
| 4 | +function book(title, author) { | ||
| 5 | + this.title = title; | ||
| 6 | + this.author = author; | ||
| 7 | + this.addPrice = addPrice; | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +var bookList = new Array(new book("Perl1", "Mohtashim"),new book("Smith", "Mohtashim"),new book("Carl", "Mohtashim"),new book("Perl2", "Mohtashim")); | ||
| 11 | + | ||
| 12 | +console.log(bookList); | ||
| 13 | +console.log("After Sorting"); | ||
| 14 | +//bookList.sort(sortBook); | ||
| 15 | +console.log(bookList); |
Experiments/Experiments07/Tutorial/array.js
0 → 100644
| 1 | + | ||
| 2 | +var alpha = ["a", "b", "c"]; | ||
| 3 | +var numeric = [1, 2, 3]; | ||
| 4 | +var alphaNumeric = alpha.concat(numeric); | ||
| 5 | +console.log("alphaNumeric : " + alphaNumeric ); | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +var numbers = [1, 4, 9]; | ||
| 9 | +var element = numbers.pop(); | ||
| 10 | +console.log("element is : " + element ); | ||
| 11 | + | ||
| 12 | +var numbers = new Array(1, 4, 9); | ||
| 13 | +var length = numbers.push(10); | ||
| 14 | +console.log("new numbers is : " + numbers ); | ||
| 15 | + | ||
| 16 | +var arr = [0, 1, 2, 3].reverse(); | ||
| 17 | +console.log("Reversed array is : " + arr ); | ||
| 18 | + | ||
| 19 | +console.log("Reversed Again : " + arr.reverse()); | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +var element = [105, 1, 2, 3].shift(); | ||
| 23 | +console.log ("Removed element is : " + element ); | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +var arr = new Array("orange", "mango", "banana", "sugar"); | ||
| 27 | +var length = arr.unshift("water"); | ||
| 28 | +console.log("Returned array is : " + arr ); | ||
| 29 | +console.log("Length of the array is : " + length ); | ||
| 30 | + |
Experiments/Experiments07/Tutorial/number.js
0 → 100644
Experiments/Experiments07/Tutorial/object.js
0 → 100644
| 1 | +function addPrice(amount) { | ||
| 2 | + this.price = amount; | ||
| 3 | +} | ||
| 4 | +function book(title, author) { | ||
| 5 | + this.title = title; | ||
| 6 | + this.author = author; | ||
| 7 | + this.addPrice = addPrice; | ||
| 8 | +} | ||
| 9 | +var myBook = new book("Perl", "Mohtashim"); | ||
| 10 | +myBook.addPrice(100); | ||
| 11 | +console.log("Book title is : " + myBook.title); | ||
| 12 | +console.log("Book author is : " + myBook.author); | ||
| 13 | +console.log("Book price is : " + myBook.price); |
Experiments/Experiments07/Tutorial/string.js
0 → 100755
| 1 | +var val = new String("test"); | ||
| 2 | + | ||
| 3 | +console.log(val.charAt(1)); | ||
| 4 | +console.log(val.charCodeAt(1)); | ||
| 5 | +console.log(val.concat("aaa")); | ||
| 6 | +console.log(val.indexOf("st")); | ||
| 7 | +console.log(val.indexOf("t")); | ||
| 8 | +console.log(val.lastIndexOf("t")); | ||
| 9 | +console.log(val.replace("te","a")); | ||
| 10 | +console.log(val.slice(2)); | ||
| 11 | +console.log(val.split("es")); | ||
| 12 | +console.log(val.substr(2,2)); |
-
Please register or login to post a comment