cors

Cross-Origin Resource Sharing

Apache

In the folders where your JavaScript files will be served from, create an .htaccess file with the following contents:

1
Header add Access-Control-Allow-Origin "*"

Nginx

Add the add_header directive to the location block that serves your JavaScript files:

1
2
3
location ~ ^/assets/ {
add_header Access-Control-Allow-Origin *;
}

js bind

1
2
3
4
5
6
7
8
9
10
window.name = 'gswin'
var geeks = {
name : "ABC",
printFunc: function(){
console.log(this.name,this);}
}

var printFunc2= geeks.printFunc;
printFunc2();
```

window.name = ‘gswin’
var geeks = {
name : “ABC”,
printFunc: function(){
console.log(this.name,this);}
}

var printFunc2= geeks.printFunc.bind(geeks);
printFunc2();
```