v2.5.2
Giriş yap

javascript template literal object

murat34
289 defa görüntülendi
const stil =function(r,g,b){

                return  {
                        width:'300px',
                        height:'300px',
                        background: ` rgb(${r},${g},${b} ) `
                     }

    } 
    console.log(stil(50,50,50))
    

// {width: '300px', height: '300px', background: 'rgb(50,50,50 )'}

background değerini objenin içine template literal ile koyunca tırnaklı alıyor.
normalde ise mesela
console.log(stil(50,50,50).background)
// rgb(50,50,50)
bu şekilde alabiliyorum.Olması gereken istediğim bu.
objenin içinde template literal neden tırnaklı dönüyor.

Cevap yaz
Cevaplar (2)
tayfunerbilen
577 gün önce

cunku string, bunda bir hata yok? yapmak istedigin nedir?

murat34
577 gün önce

background a component her render olduğunda random renk vermek.