SHARE
TWEET

Untitled

a guest Oct 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Object creator:
  2.  
  3. function createMyObject() {
  4.   return myObject = {
  5.     foo: "bar",
  6.     answerToUniverse: 42,
  7.     "olly olly": "oxen free",
  8.     sayHello: function() {
  9.       return "hello"
  10.     }
  11.   }};
  12.  
  13.  
  14.  
  15.   Update object:
  16.  
  17.   function updateObject(obj) {
  18.   obj.foo = "foo";
  19.   obj.bar = "bar";
  20.   obj.bizz = "bizz";
  21.   obj.bang = "bang";
  22.   return obj;
  23. }
  24.  
  25.  
  26. Self-reference:
  27.  
  28. function personMaker() {
  29.   var person = {
  30.     firstName: 'Paul',
  31.     lastName: 'Jones',
  32.     fullName: function() {
  33.      return `${this.firstName} ${this.lastName}`
  34.     },
  35.   };
  36.   return person;
  37. }
  38.  
  39.  
  40. Key Deleter:
  41.  
  42. function keyDeleter(obj) {
  43.   delete obj.bar;
  44.   delete obj.foo;
  45.   return obj;
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top