Created
October 31, 2019 10:04
-
-
Save hillbilly300/6a2a4022684330638c20de1792a39fd6 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kejekuc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//jshint esnext:true | |
//functions | |
const user = { | |
name:'Waqar Hussain', | |
age:23, | |
male:true | |
} | |
//function | |
function getUserNameAndAgeAsArray(){ | |
var userPropArray = [] | |
for (let userProperty in user){ | |
userPropArray.push(user[userProperty]) | |
} | |
return userPropArray | |
} | |
function convertArrayIntoNestedArray(userArr=[]){ | |
return userArr.map(function elToArray(el){ | |
return [el] | |
}) | |
} | |
function printUserObject(){ | |
console.log(user) | |
console.log(convertArrayIntoNestedArray(getUserNameAndAgeAsArray())) | |
return user | |
} | |
printUserObject() | |
//function expressions (Fn.Ex) | |
/** | |
1.Anonymous F.E | |
2.Named F.E | |
*/ | |
//anonymous function expression | |
const printUserName = function(userName){ | |
console.log(userName) | |
} | |
printUserName(user.name) | |
//named function expression | |
const printUser = function printUser(user){ | |
console.log(user) | |
} | |
printUser(user) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//jshint esnext:true | |
//functions | |
const user = { | |
name:'Waqar Hussain', | |
age:23, | |
male:true | |
} | |
//function | |
function getUserNameAndAgeAsArray(){ | |
var userPropArray = [] | |
for (let userProperty in user){ | |
userPropArray.push(user[userProperty]) | |
} | |
return userPropArray | |
} | |
function convertArrayIntoNestedArray(userArr=[]){ | |
return userArr.map(function elToArray(el){ | |
return [el] | |
}) | |
} | |
function printUserObject(){ | |
console.log(user) | |
console.log(convertArrayIntoNestedArray(getUserNameAndAgeAsArray())) | |
return user | |
} | |
printUserObject() | |
//function expressions (Fn.Ex) | |
/** | |
1.Anonymous F.E | |
2.Named F.E | |
*/ | |
//anonymous function expression | |
const printUserName = function(userName){ | |
console.log(userName) | |
} | |
printUserName(user.name) | |
//named function expression | |
const printUser = function printUser(user){ | |
console.log(user) | |
} | |
printUser(user)</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jshint esnext:true | |
//functions | |
const user = { | |
name:'Waqar Hussain', | |
age:23, | |
male:true | |
} | |
//function | |
function getUserNameAndAgeAsArray(){ | |
var userPropArray = [] | |
for (let userProperty in user){ | |
userPropArray.push(user[userProperty]) | |
} | |
return userPropArray | |
} | |
function convertArrayIntoNestedArray(userArr=[]){ | |
return userArr.map(function elToArray(el){ | |
return [el] | |
}) | |
} | |
function printUserObject(){ | |
console.log(user) | |
console.log(convertArrayIntoNestedArray(getUserNameAndAgeAsArray())) | |
return user | |
} | |
printUserObject() | |
//function expressions (Fn.Ex) | |
/** | |
1.Anonymous F.E | |
2.Named F.E | |
*/ | |
//anonymous function expression | |
const printUserName = function(userName){ | |
console.log(userName) | |
} | |
printUserName(user.name) | |
//named function expression | |
const printUser = function printUser(user){ | |
console.log(user) | |
} | |
printUser(user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment