Scope question: var undefined



does anyone know why my is undefined?

I thought, the var config should be part of the global scope (the file: server.js which we see below)


import { Meteor } from 'meteor/meteor';
var QRS = require('qrs');
var config = {
	"host": '',
	"useSSL": false,
	"xrfkey": 'ABCDEFG123456789',
	"authentication": "header",
	"virtualProxy": "hdr",
	"headerKey": 'hdr-usr',
	"headerValue": '2008ENT\\Qlik',
	isSecure: true

var qrs = new QRS(config);

Meteor.startup(() => {
    var qsocks = require('qsocks');

    var config = {
    	isSecure: true


let me quess… because it already refers to itself? the config of the function…?


Yes - the config definition in your startup function is overriding the config outside of the function. Use a different name inside your startup function, like startupConfig. If you want full details on why this is the case, read the Chapter 1: What is Scope? chapter from the You Don’t know JS: Scope & Closures book. It will take you through compiler theory and why it matters in JS.