From 52f84bfe5a9e71e0873d8b018423ad1b6904be93 Mon Sep 17 00:00:00 2001 From: Wlodek Bzyl Date: Thu, 28 Jun 2012 14:00:59 +0200 Subject: [PATCH] =?UTF-8?q?doda=C5=82em=20getteGenerator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getterGenerator.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 getterGenerator.js diff --git a/getterGenerator.js b/getterGenerator.js new file mode 100644 index 0000000..4a66243 --- /dev/null +++ b/getterGenerator.js @@ -0,0 +1,16 @@ +function getterGenerator( property ) { + return function ( obj ) { + return obj[property]; + }; +} + +var cx = getterGenerator( "cx" ), + r = getterGenerator( "r" ); + +console.log("cx: ", cx( { cx: 'hello world', r: 5 } )); +console.log("r:", r( { cx: 'hello world', r: 5 } )); + +var o = { cx: 'witaj świecie', r: 4 }; + +console.log("cx: ", cx( o )); +console.log("r:", r( o ));