Guest User

Untitled

a guest
Dec 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. var SomeObject = function(a, b){
  2. this.a = a;
  3. this.b = b
  4. }
  5.  
  6. SomeObject.prototype.toString = function(){
  7. return [ this.a, this.b ].join(' ')
  8. }
  9.  
  10. var objInstance = new SomeObject('this', 'that');
  11.  
  12. console.log(objInstance + '') // this that
  13. console.log(("" + objInstance).split('')) // [ 't', 'h', 'i', 's', ' ', 't', 'h', 'a', 't' ]
  14. console.log(objInstance.split()) // error
Add Comment
Please, Sign In to add comment