Home > oop > JavaScript Closure

JavaScript Closure

JavaScript Closure dianggap sebagai konsep yang advanced. Berikut ini beberapa definisi singkat yang akan memudahkan pemahaman tentang konsep tersebut:

closure: where a function remembers what happens around it; one function defined inside another (secrets of javascript closures, stuart langridge)

A closure takes place when a function creates an environment that binds local variables to it in such a way that they are kept alive after the function has returned (Understanding JavaScript Closures, Rob Gravelle)

Two one sentence summaries (JavaScript Closures for Dummies, http://blog.morrisjohns.com/):

  • a closure is the local variables for a function – kept alive after the function has returned, or
  • a closure is a stack-frame which is not deallocated when the function returns
Categories: oop
  1. May 16, 2010 at 3:52 pm

    ini diajarin di kuliah OOP juga Bu?

  2. May 17, 2010 at 3:47 pm

    Dikenalkan sedikit saat membahas fungsi di JavaScript. Ternyata di belakangnya ada konsep yang rumit. Definisi di atas hanya definisi praktis…
    Kalau mau sharing ttg topik ini boleh lho…

  3. May 24, 2010 at 10:02 am

    wah, sharing di kelas?
    keren tuh idenya.

  4. May 29, 2010 at 3:12 pm

    Kelasnya sudah berakhir. Sharing di blog ini saja…🙂

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: