Click here to Skip to main content
15,887,453 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionHow to hide f12 devloper tool from the browser? Pin
Member 1345865211-Oct-17 0:30
Member 1345865211-Oct-17 0:30 
AnswerRe: How to hide f12 devloper tool from the browser? Pin
F-ES Sitecore11-Oct-17 1:03
professionalF-ES Sitecore11-Oct-17 1:03 
QuestionAngular releases Pin
BrunoFaitalaas9-Oct-17 22:36
BrunoFaitalaas9-Oct-17 22:36 
AnswerRe: Angular releases Pin
Nathan Minier10-Oct-17 2:44
professionalNathan Minier10-Oct-17 2:44 
GeneralRe: Angular releases Pin
Karthik_Mahalingam11-Oct-17 21:21
professionalKarthik_Mahalingam11-Oct-17 21:21 
PraiseRe: Angular releases Pin
Jeremy Falcon7-Nov-17 22:30
professionalJeremy Falcon7-Nov-17 22:30 
QuestionWhy not the output is 3 in java script object for the line console.log(home.count) Hope i am making it clear. Pin
Member 110968437-Oct-17 5:14
Member 110968437-Oct-17 5:14 
AnswerRe: Why not the output is 3 in java script object for the line console.log(home.count) Hope i am making it clear. Pin
Richard Deeming9-Oct-17 8:52
mveRichard Deeming9-Oct-17 8:52 
Because the return statement at the end of the home function creates a copy of the value of the count variable at the point where the method returns. There is no connection between that copy and the local variable, so when the "work" functions update the local variable, that change is not reflected in the returned object.

Imagine how difficult it would be to write code in a language where that was not the case!
JavaScript
var x = 42;
var y = x;
x = 0; // What value should y have at this point?

You'll need to change the returned object so that count is a function that returns the current value of the local variable:
JavaScript
var home = function() {
    ...
    return {
        caller: caller,
        count: function(){
            return count;
        }
    };
};

var h = home();
h.caller().job1();
h.caller().job2();
h.caller().job1();
console.log(h.count());




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


QuestionBug in try catch statement can I can't find where. Pin
Jason Lemon3-Oct-17 16:11
Jason Lemon3-Oct-17 16:11 
GeneralRe: Bug in try catch statement can I can't find where. Pin
PIEBALDconsult3-Oct-17 17:28
mvePIEBALDconsult3-Oct-17 17:28 
QuestionRe: Bug in try catch statement can I can't find where. Pin
Richard MacCutchan3-Oct-17 21:44
mveRichard MacCutchan3-Oct-17 21:44 
AnswerRe: Bug in try catch statement can I can't find where. Pin
Karthik_Mahalingam4-Oct-17 17:53
professionalKarthik_Mahalingam4-Oct-17 17:53 
AnswerRe: Bug in try catch statement can I can't find where. Pin
ZurdoDev11-Oct-17 9:48
professionalZurdoDev11-Oct-17 9:48 
AnswerRe: Bug in try catch statement can I can't find where. Pin
Weavr8-Apr-18 1:58
Weavr8-Apr-18 1:58 
QuestionJavascript Pin
Member 134419482-Oct-17 15:59
Member 134419482-Oct-17 15:59 
AnswerRe: Javascript Pin
Richard MacCutchan2-Oct-17 21:51
mveRichard MacCutchan2-Oct-17 21:51 
AnswerRe: Javascript Pin
GKP19923-Oct-17 23:52
professionalGKP19923-Oct-17 23:52 
AnswerRe: Javascript Pin
Karthik_Mahalingam4-Oct-17 17:51
professionalKarthik_Mahalingam4-Oct-17 17:51 
QuestionDocument.OnKeyDown Pin
Member 1342709424-Sep-17 10:58
Member 1342709424-Sep-17 10:58 
QuestionRe: Document.OnKeyDown Pin
ZurdoDev2-Oct-17 3:11
professionalZurdoDev2-Oct-17 3:11 
AnswerRe: Document.OnKeyDown Pin
Richard MacCutchan2-Oct-17 6:01
mveRichard MacCutchan2-Oct-17 6:01 
QuestionHow to upgrade apps from angular 1 to angular 4 Pin
GKP199220-Sep-17 22:15
professionalGKP199220-Sep-17 22:15 
AnswerRe: How to upgrade apps from angular 1 to angular 4 Pin
Nathan Minier2-Oct-17 1:54
professionalNathan Minier2-Oct-17 1:54 
GeneralRe: How to upgrade apps from angular 1 to angular 4 Pin
GKP19923-Oct-17 23:50
professionalGKP19923-Oct-17 23:50 
QuestionJavascript inner function,to which object does an inner functions belongs to Pin
Member 1335414214-Sep-17 21:16
Member 1335414214-Sep-17 21:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.