Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:36:18+00:00 2026-05-23T13:36:18+00:00

There is a nested function (a function inside a function) that looks something like

  • 0

There is a nested function (a function inside a function) that looks something like this along with some tests that I added:

function addImage( ....., borderColor){
   var height;
   var width;
   var imageObj = new Image();
   alert(' just before inner function is: ' + borderColor); 
   imageObj.onload = function(){
      alert(' just after inner function is: ' + borderColor);   

The first alert shows the correct color, but the second alert is ‘null’.

How can I get the variable borderColor inside of the nested function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:36:19+00:00Added an answer on May 23, 2026 at 1:36 pm

    test case here it works fine for me

    • Are you sure the second alert is the alert(' just after inner function is: ' + borderColor); part ?
    • Are you sure the variable borderColor is not used elsewhere ?
    • what browser are you testing on ?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to crate nested union types in F#? Something like this
I have a series of nested UL's that are like this: <ul class=categorySelect id=>
I need parse a string inside a parenthesis, which looks like (A, B, C),
Suppose we have to use in some function deeply nested pointer very extensively: function
I've having trouble with nested while loops. I've created this function to list three
There is nested listviews and I want to register a button in the second
I have a ViewController class called GamePlay. In GamePlay there is a nested class
I'am filling tables in .net DataSet with data. There is a nested relation between
When a span is nested in a div with a different background there's a
In my application, there is a resource, machine, and a nested resource from machine:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.