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

  • Home
  • SEARCH
  • 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 8754955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:44:46+00:00 2026-06-13T13:44:46+00:00

I recently read a tutorial on CSS browser feature detection… The end product was

  • 0

I recently read a tutorial on CSS browser feature detection… The end product was something like this…

var prefix = ['Moz', 'webkit', 'O', 'ms', 'Khtml'],
    test_style = document.createElement('div').style;

var css_check = function(prop) {
    if (prop in test_style) {
        return true;
    }
    for (var i = 0; i < prefix.length; i++) {
        if (prefix[i] + prop in test_style) {
            return true;
        }
    }
    return false;
};

css_check('whatev_css_property');

The part I dont understand is this…

if (prop in test_style) or if (foo in bar).

From what I’ve read if (foo in bar) is used to check if a value is in an array but I might be wrong here, I haven’t found much documentation on this. Also, if this is used to check values in an array HOW is test_style = document.createElement('div').style an array? Doesn’t make sense…

I am terrible confused. Any clarification would be greatly appreciated.

  • 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-06-13T13:44:48+00:00Added an answer on June 13, 2026 at 1:44 pm

    The in operator is used to check for the presence of a key in an array or object, e.g.

    3 in [1, 2, 3] // false, since the array indices only go up to 2
    2 in [1, 2, 3] // true
    'x' in { x: 5 } // true
    'toString' in Object.prototype // true
    

    The style property there is an instance of CSSStyleDeclaration, which contains properties for each supported style attribute in the active browser.

    The code snippet you gave in your post checks whether the viewing browser supports some version of that style (either the official one or with one of a number of common vendor prefixes).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read a post online about rotating text with css. This appealed to
I recently read in this tutorial that certain jQuery leaks are trackable through the
Recently, I read this article: http://download.oracle.com/javase/tutorial/extra/generics/wildcards.html My question is, instead of creating a method
I recently read a blog in Nodejitsu and I am wondering how this piece
I recently read a jQuery tutorial about best practices. I usually run all my
I recently discovered this very useful Netbeans tutorial for creating a simple JSF 2
I recently read an article talking about the Java annotations, and on this latter
Recently I read a nice tutorial How to Authenticate Users With Twitter OAuth even
I recently started learning Emacs . I went through the tutorial, read some introductory
I recently read this thread on MSDN . So I was thinking of using

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.