I am reading over this code and the article on  about closures:  function outer() {      var reference = 0;      return function() {         reference += 1;         return reference;     } }  var x = outer(); x(); x() x() console.dir( x() );   Yet, I am baffled at how this code remembers state. For some reason the author of the code decided to name a variable reference. Only thing that comes to mind is the, "physical address" meaning in this context.  When I see the lines of code from var x = ... I am thinking the following:   assign the anonymous function to the variable x. At this time of execution the reference variable of the outer function is 0 and so is it in the inner function execute the inner function adding the variable reference to 1 then I loose track   From running the code all I can see is that the inner function creates some type of reference/pointer ,if you will, to the outer functions reference variable which is updated each time the closure is executed. For some reason the reference variable's value persists upon further execution almost like a static variable in php. Is this why MDN says that a closure "remembers" its environment?  Any step by step explanation would help.
How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?  I have seen  given on Wikipedia, but unfortunately it did not help.
What is the difference between DX format and FX format lenses, and which to choose for what purpose? What is the difference between DX format and FX format lenses, and which to choose for what purpose?  What are the pros and cons of both? Do I need a visa to transit (or layover) in the Schengen area? I found many related questions on this site but I am still not sure about the rules. How can I decide if I need a visa to transit? Schengen members as of May 2021 are as follows:  Austria Belgium Czech Republic Denmark (excluding Greenland and the Faroe Islands - but an open border with the Schengen Area is maintained) Estonia Finland France (excluding overseas departments and collectivities) Germany Greece Hungary Iceland Italy Latvia Liechtenstein Lithuania Luxembourg Malta Netherlands (excluding Aruba, Curaçao, Sint Maarten and the Caribbean Netherlands) Norway (excluding Svalbard) Poland Portugal Slovakia Slovenia Spain (except Ceuta and Melilla) Sweden Switzerland Word for someone who repeats words Exeception on After Insert, Record is read only I'm writing a trigger for new opportunity products to populate  a field Product_Category__c (on opportunity lineitem) getting the value from Product_Category_new__c (on Product).  This is my trigger:  trigger SetProductCategory on OpportunityLineItem (after insert) {      for (OpportunityLineItem opplineitem: Trigger.new) {                    opplineitem.Product_Category__c =  opplineitem.PricebookEntry.Product2.Product_Category_new__c;     }      }   I get this error message:     execution of AfterInsert caused by: System.FinalException: Record is read-only   I have tried with before insert;in this case there aren't errors but the value Product category it's not saved on Opportunity Line item.  I have found that:  In a after insert trigger is not allowed change field using trigger.new  Please can you suggest a solution for this? i would like to copy the value Product category (Product) on Product Category (Opportunity Product)  after the insert of the new opportunity products.  Thanks in advantage for any advice.  Br What are the scope restrictions for setting shopt extglob. and other options? My non-interactive bash shell has extglob off. I would like to turn it on in the statement immediately before a command, but I have noticed that when shopt -s extglob is within an if .. then .. else block, it somehow does not register.   The following extglob-dependant command is not valid: syntax error near unexpected token '('.     Where can extglob be set, and why is there a restriction, at all? Does this apply to other options?  ... GNU bash 4.1.5     This works:    shopt -s extglob if true ;then     touch a.bcd; ls a.@(bcd) fi   This fails:    if true ;then     shopt -s extglob     touch a.bcd; ls a.@(bcd) fi ... line 17: syntax error near unexpected token `(' ... line 17: `touch a.bcd; ls a.@(bcd)' How many numbers of 6 digits, that can be formed with digits 2,3,9. And also divided by 3? How many numbers of 6 digits, that can be formed with digits 2,3,9. And also divided by 3?  $$$$ I was trying to to add 2^6 (when there is no 2)+ C(6,2)2^2 (when 2 can be in two places)+C(6,3)2^3 (when 2 can be in three places)... How do I make a bootable USB from Windows? How do I add a DOM element with jQuery? I have read about copying files with terminal but these examples will help me a lot. So here is what I want to do:  Examples:   I have a file in /home/levan/kdenlive untitelds.mpg and I want to copy this file to /media/sda3/SkyDrive and do not want to delete any thing in SkyDrive directory. I have a file in /media/sda3/SkyDrive untitelds.mpg and I want to copy this file to /home/levan/kdenlive  and do not want to delete any thing in kdenlive directory  I want to copy a folder from home directory to sda3 and do not want to delete any thing on sda3 directory and opposite I want to cut a folder/file and copy to other place without deleting files in that directory I cut it into. Load jQuery from Stack's CDN if Google's CDN is blocked (or always) If I would show someone a yellow object and ask them, "is this object yellow?" That person would say "yes".  But I could never know if my perception of the color yellow is the same as that other person's. Because he or she could actually be seeing, what I know to be the color green. But then tells me that its the color yellow because that has been taught to him or her from young age.  So how can you test if people are really seeing the same color?  Question closed and can now be found @ How do I prove the following statement by induction?  $$n^2 \lt 2^n$$  $P(n)$ is the statement $n^2 \lt 2^n$  Claim: For all $n \gt k$, where $k$ is any integer, $P(n)$  (since $k$ is any integer, I assume I have to prove this for positive and negative integers)  So let base case be $P(1)$, and I have to prove $P(n)$ for $n \ge 1$ and $n \lt 1$  $P(1)$ is $1^2 \lt 2^1$ which is clearly true.  Induction hypothesis: $k^2 \lt 2^k$  Inductive step $(k+1)^2 \lt 2^{(k+1)}$  $(k+1)^2 = k^2 + 2k + 1$  $k^2 + 2k + 1 \lt 2^k + 2k + 1$ by inductive hypothesis  Not sure how to proceed. Is my previous intuition that I have to prove this for $n \ge 1$ and $n \lt 1$ correct? Apparently I cannot count. I think there are three files in /media  $ tree /media /media ├── foo ├── onex └── zanna 3 directories, 0 files   However, ls -l finds 12.  $ ls -l /media total 12 drwxr-xr-x  2 root root 4096 Jul 31 20:57 foo drwxrwxr-x  2 root root 4096 Jun 26 06:36 onex drwxr-x---+ 2 root root 4096 Aug  7 21:17 zanna   And, if I do ls -la I get only . and .. in addition to the above, but the count is total 20  What's the explanation? Are there good reasons why it's a better practice to have only one return statement in a function?   Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function? SharePoint 2013 REST display lookup fields? I am using SharePoint 2013 REST to show data from my list,  one of my field in announce list is AnnouncedBy which is a user packer field  or is a lookup field   how can I display it or get it using SharePoint 2013 REST?   var app = angular.module('SmartphoneOSList', ['ngSanitize']);    app.controller('ListController', function ($scope, $http) {    $http({       method: 'GET',       url: "https://myserver/_api/web/lists/getByTitle('announce')/items?$top=2&amp;$orderby=Modified desc",       headers: { "Accept": "application/json;odata=verbose" }      }).success(function (data, status, headers, config) {        $scope.items = data.d.results;       }).error(function (data, status, headers, config) {       //...     });   }); Is it true that a dihedral group is nonabelian?  I'm not sure if the result is true. I checked it for some lower order and I think the result may correct.   But I failed to prove/disprove the result. Non-blocking Synchronous AJAX Delayed choice entanglement swapping: why are Alice & Bob's measurements useless without Victor's? How does the Battle Booster work? I received the 80% battle point booster. It has 500 minutes on it and says the booster is only consumed when battle points are earned. Does this mean I can play 500 minutes of matches during a week and earning the bonus points? Or does it wear off in 500 minutes after equipping it?  Also it says my team is granted a 16% bonus. Does this stack? Do i get another 16% if I and another player wears it? Since it's a new item with the present chest it would be wise to use it later if the bonus does not stack. Don't we have single sign-on for all Stack Exchange sites? I would like to use many sites in the Stack Exchange network, but I need to login to each site separately. Though it's easy, can't we solve this problem? I know each site has a different url :( but is there any way?