Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INDEX.HTML
- <!DOCTYPE html>
- <html>
- <head>
- <!-- <script src="js/functions.js"></script> -->
- <script src="js/objects.js"></script>
- </head>
- <body></body>
- </html>
- FUNCTIONS.JS
- function doSomething() {
- var value = null;
- for(var i = 0; i < 3; i++) {
- value = function() {
- console.log(i);
- }
- }
- return value;
- }
- var result = doSomething();
- result();
- function doSomething1() {
- var value = null;
- for(let i = 0; i< 3; i ++) {
- value = function() {
- console.log(i);
- }
- }
- return value;
- }
- var result1 = doSomething1();
- result1();
- console.log(result1.prototype);
- console.log(result.prototype);
- function sum(a, b) {
- return a + b;
- }
- function sum1a(a, b=0) {
- return a + b;
- }
- function sum1b(a=0, b=0) {
- return a + b;
- }
- function sum2(a, b) {
- if(typeof a == 'undefined') a = 0;
- if(typeof b == 'undefined') b = 0;
- return a + b;
- }
- function sum3(a, b) {
- return (a || 0) + (b || 0);
- }
- console.log('Suma cu doi parametri', sum(5,4));
- console.log('Suma cu un parametru', sum1a(4));
- console.log('Suma cu zero parametri', sum1b());
- console.log('Suma2', sum2());
- console.log('Suma3', sum3());
- OBJECTS.JS
- var person = {
- name: 'Gigel',
- surname: 'Popel'
- }; //object literals
- //var person1 = new Object;
- console.log(person);
- //console.log(person1);
- var student = Object.create(person);
- console.log(student);
- student.grupa = 1085;
- console.log(student.name);
- var employee = Object.create(student);
- employee.salary = 5000;
- console.log(employee['salary']);
- console.log(employee);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement