Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function ProtoError (code) {
  2. const error={
  3. "1":{
  4. "code": 100,
  5. "text": "foo"
  6. },
  7. ///...
  8. }
  9. self=this
  10. return error[code]
  11. }
  12. ProtoError.prototype.fullText = function(){
  13. return this.code+" "+this.text
  14. }
  15.  
  16. a = new ProtoError(100) //
  17. console.log(a) // { code: 100, text: 'foo'}
  18. b=a.fullText() //a.fullText is not a function
  19.  
  20. {
  21. "code": 100,
  22. "text": "foo"
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement