it has two functions show_items() one as a global function and the other as a function inside temp , i have commented what i get in the console .
Code: Select all
<script type="text/javascript">
var movies = 'Love them !!',
radio = 'antique';
var temp = {
movies : 'Love them !! inside temp',
radio : 'antique.. inside temp',
show_items : function show_items(){
console.log(this.movies + " " + this.radio)
}
}
function show_items(){
console.log(this.movies + " " + this.radio)
}
show_items();
temp.show_items();
i get the below in the console :
Love them !! antique
Love them !! inside temp antique.. inside temp
</script>
Code: Select all
show_items : function show_items(){
console.log(this.movies + " " + this.radio)
}()
Code: Select all
var movies = 'Love them !!',
radio = 'antique';
var temp = {
movies : 'Love them !! inside temp',
radio : 'antique.. inside temp',
show_items : function show_items(){
console.log(this.movies + " " + this.radio)
}()
}
function show_items(){
console.log(this.movies + " " + this.radio)
}
show_items();
i get the following on the console :
Love them !! antique
Love them !! antique