SlideShare ist ein Scribd-Unternehmen logo
1 von 7
S53

#1
1-1 hashmap
1-2 window
1-3 function & execution context


2012.10.17 20:30 ~ 22:30
text = Javascript

                                                result = Parsing Text

                                                result = hashmap, hashmap, hashmap,
                                                hashmap, hashmap, hashmap, hashmap,
                                                hashmap, hashmap, hashmap,.....


Bernstein hash                                  hashmap,   hashmap, hashmap,   hashmap,
Fowler-Noll-Vo hash function                    hashmap,   hashmap, hashmap,   hashmap,
Jenkins hash function                           hashmap,   hashmap, hashmap,   hashmap,
Pearson hashing                                 hashmap,         result
                                                           hashmap, hashmap,   hashmap,
Zobrist hashing                                 hashmap,   hashmap, hashmap,   ...



unsigned long hash(unsigned char *str){
     unsigned long hash = 5381;
     int c;
     while( c = *str++ )
             hash = ((hash << 5) + hash) + c;

     return hash;
}
<html>                ( function window(){
<head>                    this = window||arguments.callee;

<script>                  var val0, val1;
var val0 = 'test0';
key0 = 3;                 val0 = 'test0';
function a(){}            this.key0 = 3;
</script>                 function a(){};

<body>                    val1 = 'test1';
                          this.key1 = 4;
<script>                  function b(){};
var val1 = 'test1';
key1 = 4;             } )();
function b(){}
</script>

</body>
</html>
wkey = "key";                     Function['test'] = {
var wVar = "win";                      parent: windowEC,
                                       locals:{
function test( a ){                           a:null,
     var b;                                   b:null
     b = ':test';                      },
     ( function(){                     arguments:['a'],
          var c;                       body:'.....'
          c = ':c';               };
          alert( a + b + c );
          alert( wKey + wVar );
     } )();
}

test( 'hello' );                  testEC = {
// hello:test:c                        a:null,
                                       b:null,
                                       arguments:{
                                              0:'hello',
                                              length:1,
                                              callee: Function['test']
                                       },
                                       this: window,
                                       __parent__:Function['test'].parent,
                                       test: Function['test']
                                  };
                                  for( i = 0 ; i < testEC.arguments.length ; i++ )
                                       testEC[Function['test'].arguments[i]] =
                                              testEC.arguments[i];
wkey = "key";                     testEC.b = ':test';
var wVar = "win";                 Function['@35'] = {
                                       parent: testEC,
function test( a ){                    locals:{c:null},
     var b;                            arguments:[],
     b = ':test';                      body:'.....'
     ( function(){                };
          var c;
          c = ':c';
          alert( a + b + c );     @35EC = {
          alert( wKey + wVar );        c:null,
     } )();                            arguments:{
}                                             length:0,
                                              callee:Function['@35']
test( 'hello' );                       },
// hello:test:c                        this: window,
                                       __parent__:Function['@35'].parent,
                                       test: Function['@35']
                                  };
                                  for( var i = 0 ; i < @35EC.arguments.length ; i++ )
                                       testEC[Function['@35'].arguments[i]] =
                                              testEC.arguments[i];
wkey = "key";                     @35EC.c = ':c';
var wVar = "win";
                                  temp = @35EC.__parent__.a +
function test( a ){                    @35EC.__parent__.b +
     var b;                            @35EC.c;
     b = ':test';                 alert( temp );
     ( function(){                temp = this.wKey +
          var c;                       @35EC.__parent__. __parent__.wVar;
          c = ':c';               alert( temp );
          alert( a + b + c );
          alert( wKey + wVar );   delete @35EC;
     } )();
}                                 delete testEC;

test( 'hello' );
// hello:test:c
function getValue( $ec, $key ){
     var result, temp;

    temp = $ec;
    while( ( result = temp[$key] ) === undefined )
           if( (temp = temp.__parent__ ) === null ) break;

    if( temp !== null ) return result;

    temp = $ec.this;
    while( ( result = temp[$key] ) === undefined )
           if( (temp = temp.__prototype__ ) === null ) break;

    if( temp !== null ) return result;

    throw new error();
}



temp = @35EC.__parent__.a +                   temp = this.wKey +
     @35EC.__parent__.b +                     @35EC.__parent__. __parent__.wVar;
     @35EC.c;                                 alert( temp );
alert( temp );




temp = getVal( @35EC, 'a' ) +                 temp = getVal( @35EC, 'wKey') +
     getVal( @35EC, 'b' ) +                        getVal( @35EC, 'wVar');
     getVal( @35EC, 'c' );                    alert( temp );
alert( temp );

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Lisp
LispLisp
Lisp
 
Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.
 
Unittesting JavaScript with Evidence
Unittesting JavaScript with EvidenceUnittesting JavaScript with Evidence
Unittesting JavaScript with Evidence
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Parsing with Perl6 Grammars
Parsing with Perl6 GrammarsParsing with Perl6 Grammars
Parsing with Perl6 Grammars
 
Jason parsing
Jason parsingJason parsing
Jason parsing
 
Rのスコープとフレームと環境と
Rのスコープとフレームと環境とRのスコープとフレームと環境と
Rのスコープとフレームと環境と
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184
 
The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
 
Promise is a Promise
Promise is a PromisePromise is a Promise
Promise is a Promise
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」
 
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 

Andere mochten auch

Wow! closure in_javascript
Wow! closure in_javascriptWow! closure in_javascript
Wow! closure in_javascript
cnlangzi
 

Andere mochten auch (11)

Wow! closure in_javascript
Wow! closure in_javascriptWow! closure in_javascript
Wow! closure in_javascript
 
JavaScript closures
JavaScript closuresJavaScript closures
JavaScript closures
 
Ambient Media Worldwide Ltd Jd Lr
Ambient Media Worldwide Ltd Jd LrAmbient Media Worldwide Ltd Jd Lr
Ambient Media Worldwide Ltd Jd Lr
 
JavaScript closures
JavaScript closuresJavaScript closures
JavaScript closures
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
Closure
ClosureClosure
Closure
 
Asynchronous JavaScript and Promises
Asynchronous JavaScript and Promises Asynchronous JavaScript and Promises
Asynchronous JavaScript and Promises
 
Callbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptCallbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascript
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
JavaScript tips - Unnest callbacks and method declarations
JavaScript tips - Unnest callbacks and method declarationsJavaScript tips - Unnest callbacks and method declarations
JavaScript tips - Unnest callbacks and method declarations
 
The Top Skills That Can Get You Hired in 2017
The Top Skills That Can Get You Hired in 2017The Top Skills That Can Get You Hired in 2017
The Top Skills That Can Get You Hired in 2017
 

Ähnlich wie javascript function & closure

java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
priestmanmable
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
Neeraj Kaushik
 

Ähnlich wie javascript function & closure (20)

Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mocha
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In Depth
 
Testing most things in JavaScript - LeedsJS 31/05/2017
Testing most things in JavaScript - LeedsJS 31/05/2017Testing most things in JavaScript - LeedsJS 31/05/2017
Testing most things in JavaScript - LeedsJS 31/05/2017
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
A Test of Strength
A Test of StrengthA Test of Strength
A Test of Strength
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.js
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113
 
Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

javascript function & closure

  • 1. S53 #1 1-1 hashmap 1-2 window 1-3 function & execution context 2012.10.17 20:30 ~ 22:30
  • 2. text = Javascript result = Parsing Text result = hashmap, hashmap, hashmap, hashmap, hashmap, hashmap, hashmap, hashmap, hashmap, hashmap,..... Bernstein hash hashmap, hashmap, hashmap, hashmap, Fowler-Noll-Vo hash function hashmap, hashmap, hashmap, hashmap, Jenkins hash function hashmap, hashmap, hashmap, hashmap, Pearson hashing hashmap, result hashmap, hashmap, hashmap, Zobrist hashing hashmap, hashmap, hashmap, ... unsigned long hash(unsigned char *str){ unsigned long hash = 5381; int c; while( c = *str++ ) hash = ((hash << 5) + hash) + c; return hash; }
  • 3. <html> ( function window(){ <head> this = window||arguments.callee; <script> var val0, val1; var val0 = 'test0'; key0 = 3; val0 = 'test0'; function a(){} this.key0 = 3; </script> function a(){}; <body> val1 = 'test1'; this.key1 = 4; <script> function b(){}; var val1 = 'test1'; key1 = 4; } )(); function b(){} </script> </body> </html>
  • 4. wkey = "key"; Function['test'] = { var wVar = "win"; parent: windowEC, locals:{ function test( a ){ a:null, var b; b:null b = ':test'; }, ( function(){ arguments:['a'], var c; body:'.....' c = ':c'; }; alert( a + b + c ); alert( wKey + wVar ); } )(); } test( 'hello' ); testEC = { // hello:test:c a:null, b:null, arguments:{ 0:'hello', length:1, callee: Function['test'] }, this: window, __parent__:Function['test'].parent, test: Function['test'] }; for( i = 0 ; i < testEC.arguments.length ; i++ ) testEC[Function['test'].arguments[i]] = testEC.arguments[i];
  • 5. wkey = "key"; testEC.b = ':test'; var wVar = "win"; Function['@35'] = { parent: testEC, function test( a ){ locals:{c:null}, var b; arguments:[], b = ':test'; body:'.....' ( function(){ }; var c; c = ':c'; alert( a + b + c ); @35EC = { alert( wKey + wVar ); c:null, } )(); arguments:{ } length:0, callee:Function['@35'] test( 'hello' ); }, // hello:test:c this: window, __parent__:Function['@35'].parent, test: Function['@35'] }; for( var i = 0 ; i < @35EC.arguments.length ; i++ ) testEC[Function['@35'].arguments[i]] = testEC.arguments[i];
  • 6. wkey = "key"; @35EC.c = ':c'; var wVar = "win"; temp = @35EC.__parent__.a + function test( a ){ @35EC.__parent__.b + var b; @35EC.c; b = ':test'; alert( temp ); ( function(){ temp = this.wKey + var c; @35EC.__parent__. __parent__.wVar; c = ':c'; alert( temp ); alert( a + b + c ); alert( wKey + wVar ); delete @35EC; } )(); } delete testEC; test( 'hello' ); // hello:test:c
  • 7. function getValue( $ec, $key ){ var result, temp; temp = $ec; while( ( result = temp[$key] ) === undefined ) if( (temp = temp.__parent__ ) === null ) break; if( temp !== null ) return result; temp = $ec.this; while( ( result = temp[$key] ) === undefined ) if( (temp = temp.__prototype__ ) === null ) break; if( temp !== null ) return result; throw new error(); } temp = @35EC.__parent__.a + temp = this.wKey + @35EC.__parent__.b + @35EC.__parent__. __parent__.wVar; @35EC.c; alert( temp ); alert( temp ); temp = getVal( @35EC, 'a' ) + temp = getVal( @35EC, 'wKey') + getVal( @35EC, 'b' ) + getVal( @35EC, 'wVar'); getVal( @35EC, 'c' ); alert( temp ); alert( temp );