• 30-01-2021, 20:25:35
    #1
    Merhaba,

    Şöyle bir config dosyam var;
    module.exports = {
      nick:        "Test",
      pass:       "123321",
      email:      "test@deneme.com",
    };
    Gibi mesala aynı tanım içinde yeni bir tanım yapmak istiyorum ama nick ve pass tanımını birlestir içine eklemek istiyorum;

    module.exports = {
      nick:        "Test",
      pass:       "123321",
      email:      "test@deneme.com",
    
    birlestir: nick + pass,
    };
    birlestir olarak nick ve pass tanımını nasıl kullanabilirim?
  • 30-01-2021, 20:29:48
    #2
    export ettiğin obje olduğu için.
    kullanmak istediğin yerde örneğin.
    config['nick'] = "seeds";
    config['pass'] = "sdsdas"; yapabilirsin.
  • 30-01-2021, 20:30:08
    #3
    node js tam bilmiyorum ama var degiskenismi = module.exports->nick+module.exports->pass şeklinde birleştirebilirsin sanırım
  • 01-02-2021, 22:36:26
    #4
    Sorun çözülmüştür, ilgilenen arkadaşlara teşekkür ederim
  • 02-02-2021, 15:30:48
    #5
    Tekrar konu açmak yerine buradan sorayım;
    Tanımı Regex içerisinde nasıl kullanabilirim?

    Örnek
    var mesaj = "Selam Toprak! naber?";
    var deneme = "Toprak";
    mesaj.match(/\sdeneme\!/i); //Böyle kullandığımda mesaj içinde deneme arıyor tanımı değil.
    Tam olarak nasıl kullanabilirim?
  • 11-02-2021, 15:22:39
    #6
    Bunu kullan.

    config.js
    class Config {
     constructor(config) {
      this.config = config;
     }
    
     get birlestir() {
      returnthis.config.nick +this.nick.password;
     }
    }
    
     module.exports=newConfig({  nick:'Hebele',  password:'Hübele',});
    deneme.js
    const config = require('./config');
    
       console.log(config.birlestir); // HebeleHübele